import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import ifmo.is.lab1.MyList;

import java.util.ListIterator;

import org.junit.Test;


public class MainTest {

	@Test
	public void TestSize() {
		MyList a = new MyList();
		assertEquals(0, a.size());
		a.add(1);
		a.add(2);
		assertEquals(2, a.size());
		a.remove(0);
		assertEquals(1, a.size());
	}
	@Test
	public void TestAdd() {
		MyList a = new MyList();
		assertTrue(a.add(1));
	}
	@Test
	public void TestGet() {
		MyList a = new MyList();
		a.add(1);
		assertEquals(1, (int)a.get(0));
	}
	@Test
	public void TestIsEmpty() {
		MyList a = new MyList();
		assertTrue(a.isEmpty());
		a.add(0);
		a.remove(0);
		assertTrue(a.isEmpty());
	}
	@Test
	public void TestRemove() {
		MyList a = new MyList();
		a.add(0);
		a.add(1);
		assertEquals(0, (int)a.remove(0));
		assertEquals(1, (int)a.remove(0));
	}
	@Test
	public void TestRemoveFromCell() {
		MyList a = new MyList();
		a.add(1);
		assertTrue(a.removeFromCell(1));
	}
	@Test
	public void TestClear()
	{
		MyList a = new MyList();
		a.add(0);
		a.clear();
		assertEquals(0,a.size());
	}
	public void TestIterator()
	{
		MyList a = new MyList();
		a.add(0);
		a.add(1);
		ListIterator<Integer> it = a.iterator();
		assertEquals(0,(int)it.next());
		assertEquals(1,(int)it.next());
		assertEquals(1,(int)it.previous());
		assertEquals(0,(int)it.previous());
	}
}
